package com.gexiaobao.pigeon.ui.adapter

import android.graphics.Color
import androidx.appcompat.widget.AppCompatImageView
import androidx.appcompat.widget.AppCompatTextView
import com.chad.library.adapter.base.BaseQuickAdapter
import com.gexiaobao.pigeon.R
import com.gexiaobao.pigeon.app.base.DataBindBaseViewHolder
import com.gexiaobao.pigeon.app.model.bean.CollectGoodsResponse
import com.gexiaobao.pigeon.app.util.ImageLoaderManager
import com.gexiaobao.pigeon.app.util.SettingUtil
import com.gexiaobao.pigeon.databinding.ItemCollectGoodsListBinding

/**
 * @Author      : hxw
 * @Date        : 2023/7/8 10:43
 * @Describe    :
 */
class CollectGoodsListAdapter(data: ArrayList<CollectGoodsResponse.ListBean>) :
    BaseQuickAdapter<CollectGoodsResponse.ListBean, DataBindBaseViewHolder>(R.layout.item_collect_goods_list, data) {

    override fun convert(holder: DataBindBaseViewHolder, item: CollectGoodsResponse.ListBean) {
        val binding = DataBindBaseViewHolder.getBinding(holder) as ItemCollectGoodsListBinding
        binding.data = item
        binding.executePendingBindings()//防止列表抖动


        val tvItemCollectGoodPrice = holder.getView<AppCompatTextView>(R.id.tvItemCollectGoodPrice)
        val ivCollectGoodImage = holder.getView<AppCompatImageView>(R.id.ivCollectGoodImage)
        ImageLoaderManager.loadRoundImageOrEmpty(context, item.goodImg, ivCollectGoodImage, 12, R.drawable.shop_product_def)
        SettingUtil.setPrice(item.minPrice.toString(), tvItemCollectGoodPrice, 50, Color.BLACK)
    }
}